package com.vip.test.util;

import junit.framework.TestCase;

import org.apache.log4j.Logger;
import org.springframework.context.ApplicationContext;

import com.vip.framework.util.SpringContextUtil;
import com.vip.test.mock.UnitTestActionForward;
import com.vip.test.mock.UnitTestActionMapping;
import com.vip.test.mock.UnitTestDynaActionForm;
import com.vip.test.mock.UnitTestHttpServletRequest;
import com.vip.test.mock.UnitTestHttpServletResponse;
import com.vip.test.mock.UnitTestHttpSession;

/**
 * 测试用例都继承它.
 * 
 * @author sai
 *
 */
public class BaseTestCase extends TestCase {

	/**
	 * 在config.src的配置文件里的属性
	 * spring.context.config=/applicationContext.xml,/applicationContext-dataSourceJDBC.xml,/applicationContext-hibernate.xml
	 */
	public ApplicationContext scu;
	protected Logger log;
	
	public UnitTestActionForward forward;
	public UnitTestActionMapping mapping;
	public UnitTestHttpServletRequest request;
	public UnitTestHttpServletResponse response;
	public UnitTestDynaActionForm form;
	public UnitTestHttpSession session;
	
	public BaseTestCase(){
		super();
		scu=SpringContextUtil.getApplicationContext();
		log=Logger.getLogger(this.getClass());
		forward=new UnitTestActionForward();
		mapping=new UnitTestActionMapping();
		request=new UnitTestHttpServletRequest();
		response=new UnitTestHttpServletResponse();
		form=new UnitTestDynaActionForm();
		session=new UnitTestHttpSession();
		request.setSession(session);
	}
	
	public Object getBean(String name){
		return scu.getBean(name);
	}
}
